package org.tagging.service.factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.tagging.exception.UnSupportedLanguageException;
import org.tagging.model.*;
import org.tagging.service.AbbreviationService;
import org.tagging.service.AbstractTaggingFactory;
import org.tagging.service.TaggingService;
import org.tagging.service.UnknownWordService;

@Component
public class TaggingServiceFactory extends AbstractTaggingFactory {
    @Autowired
    private TaggingService<TaggingMalay> malayService;
    @Autowired
    private AbbreviationService<AbbreviationMalay> abbreviationMalayService;
    @Autowired
    private UnknownWordService<UnknownWordMalay> unknownWordMalayService;

    @Autowired
    private TaggingService<TaggingIndonesian> indonesianService;
    @Autowired
    private AbbreviationService<AbbreviationIndonesian> abbreviationIndonesianService;
    @Autowired
    private UnknownWordService<UnknownWordIndonesian> unknownWordIndonesianService;

    @Autowired
    private TaggingService<TaggingPhilippines> philippinesService;
    @Autowired
    private AbbreviationService<AbbreviationPhilippines> abbreviationPhilippinesService;
    @Autowired
    private UnknownWordService<UnknownWordPhilippines> unknownWordPhilippinesService;


    @Override
    public TaggingService<? extends Tagging> getTaggingService(String language) throws UnSupportedLanguageException {
        switch (language) {
            case "malay": {
                return malayService;
            }
            case "indonesian": {
                return indonesianService;
            }
            case "philippines": {
                return philippinesService;
            }
            default:
                throw new UnSupportedLanguageException("language not supported!-> " + language);
        }
    }

    @Override
    public AbbreviationService<? extends Abbreviation> getAbbreviationService(String language) throws UnSupportedLanguageException {
        switch (language) {
            case "malay": {
                return abbreviationMalayService;
            }
            case "indonesian": {
                return abbreviationIndonesianService;
            }
            case "philippines": {
                return abbreviationPhilippinesService;
            }
            default:
                throw new UnSupportedLanguageException("language not supported!-> " + language);
        }
    }

    @Override
    public UnknownWordService<? extends UnknownWord> getUnknownWordService(String language) throws UnSupportedLanguageException {
        switch (language) {
            case "malay": {
                return unknownWordMalayService;
            }
            case "indonesian": {
                return unknownWordIndonesianService;
            }
            case "philippines": {
                return unknownWordPhilippinesService;
            }
            default:
                throw new UnSupportedLanguageException("language not supported!-> " + language);
        }
    }
}
